import java.util.Scanner;

/**
 * LearnObjectOriented
 */
public class LearnObjectOriented {
    public static void main(String[] args) {
        breakAndContinue();
    }

    static void stdinOutput() {
        System.out.println("Hello World");
    }

    static void stdinInput() {
        // 创建Scanner对象
        var scanner = new Scanner(System.in);
        // 打印提示
        System.out.print("Input your name: ");
        // 读取一行输入并获取字符串
        String name = scanner.nextLine();
        // 打印提示
        System.out.print("Input your age: ");
        // 读取一行输入并获取整数
        int age = scanner.nextInt();
        // 格式化输出
        System.out.printf("Hi, %s, you are %d\n", name, age);
        // 关闭！！！
        scanner.close();
    }

    static void ifUsed() {
        if (true) {
            System.out.println("if true");
        } // else if { ... } else{ ... }
    }

    static void swichUsed(int num) {
        switch (num) {
            case 200:
                System.out.println("case 200");
                break;
            case 400:
                System.out.println("case 400");
            default:
                break;
        }
    }

    static void whileUsed() {
        int num = 1;
        while (num < 10) {
            System.out.println(num);
            num++;
        }
    }

    static void forUsed() {
        int[] nums = new int[] { 1, 2, 3, 4 };
        for (int i = 0; i < nums.length; i++) {
            System.out.println(nums[i]);
        }
    }

    static void breakAndContinue() {
        int[] nums = new int[] { 1, 2, 3, 4 };
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] == 1) {
                continue;
            } else if (nums[i] == 3) {
                break;
            }
            System.out.println(nums[i]); // only print 2
        }
    }
}